#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int bin_search(int arr[], int right, int r)
{
	int left = 0;
	int mid = 0;
	int find = 0;
	while (right > left)
	{
		mid = (right + left) / 2;
		if (r > mid)
		{
			left = mid + 1;
		}

		else if (r < mid)
		{
			right = mid - 1;
		}

		else
		{
			find = 1;
			break;
		}
	}

	if (1 == find)
	{
		return mid;
	}
	else
	{
		return (-1);
	}
}
int main()
{
	int left = 0;
	int arr[10] = { 1,2,3,4,5,6,7,8,9,10 };
	int right = 0;
	right = sizeof(arr) / sizeof(arr[0]);
	int r = 5;
	int print = bin_search(arr,right,r);
		printf("%d", print);
	return 0;
}